package com.veer.shop.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.veer.shop.annotation.ApiControllerLog;
import com.veer.shop.annotation.ApiSecured;
import com.veer.shop.config.ApiUrlConfig;
import com.veer.shop.param.BrandParam;
import com.veer.shop.pojo.ProductBrand;
import com.veer.shop.pojo.ResponseData;
import com.veer.shop.service.impl.admin.BrandServiceImpl;

/**
 * 商品品牌  控制器
 * 
 * @author WangBin
 * 2020年9月22日-下午5:52:04
 */
@RestController
public class BrandController {
	
	@Autowired
	private BrandServiceImpl productBrandServiceImpl;
	
	/**
	 * 获取商品品牌列表
	 */
	@ApiSecured
	@ApiControllerLog(description = "获取品牌列表")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_BRAND_LIST_URL, method = RequestMethod.GET)
	public ResponseData<?> getList(@RequestBody(required = false) BrandParam brandListParam, @RequestParam(name = "page_no", defaultValue = "1", required = false) int pageNo, @RequestParam(name = "page_size", defaultValue = "20", required = false)int pageSize)
	{
		return productBrandServiceImpl.getAll(brandListParam, pageNo, pageSize);
	}
	
	/**
	 * 新增|更新商品品牌
	 */
	@ApiSecured
	@ApiControllerLog(description = "新增|更新商品品牌")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_BRAND_UPDATE_URL, method = RequestMethod.POST)
	public ResponseData<?> update(@RequestBody ProductBrand brand)
	{
		return productBrandServiceImpl.update(brand);
	}
	
	/**
	 * 删除商品品牌
	 */
	@ApiSecured
	@ApiControllerLog(description = "删除商品品牌")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_BRAND_DELETE_URL, method = RequestMethod.POST)
	public ResponseData<?> delete(@RequestParam(name = "brand_id", defaultValue = "") String brandId)
	{
		return productBrandServiceImpl.delete(brandId);
	}
	
	/**
	 * 商品品牌详情
	 */
	@ApiSecured
	@ApiControllerLog(description = "商品品牌详情")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_BRAND_GET_URL, method = RequestMethod.GET)
	public ResponseData<?> get(@RequestParam(name = "brand_id", defaultValue = "") int brandId)
	{
		return productBrandServiceImpl.get(brandId);
	}
}
